#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
import MySQLdb


def myprint(obj, end='\n'):
    sys.stdout.write(str(obj) + end)


def main():
    db = MySQLdb.connect(host='localhost', user='root',
                         passwd='', db='mysql')
    cursor = db.cursor()
    cursor.execute(r'show databases')
    result = cursor.fetchall()
    myprint(result)

    cursor.execute(r'use test')
    cursor.execute(r'show tables')
    result = cursor.fetchall()
    myprint(result)

    cursor.close()


if __name__ == '__main__':
    main()
    myprint('done')
